import { Evaluate } from 'evaluate-model.js';

var evaluate = new Evaluate();
var judge=true;
Page({
	data:{
      height:"160rpx",
      imgUrl:"../../../images/icon-bottom.png",
      more:"更多",
      currentTab:0,
      page:0,
      pages:'',
      is_more:0
	},
	onLoad: function(options){
		var  id=options.id;
    this.setData({
        id:id
    });
    this._loadData(id);
	},
  _loadData: function (id, callback) {
    var that = this;
    var page=this.data.page+1;
    //获得product信息
    evaluate.getEvaluateInfo(id,page, (data) => {
      wx.hideLoading();
      that.setData({
        page:that.data.page+1,
        evaluate: data['evaluate'],
        count:data['count'],
        pages:data['count']/10,
        gods:data['gods'],
        is_img:data['is_img'],

      });
    });
  },
  onReachBottom: function () {
    var  page=this.data.page;
     var id=this.data.id;
      console.log(this.data.page);
    if (page<=parseInt(Math.ceil(this.data.pages)))
    {
       wx.showLoading({
           title:  "数据加载中",  
           mask: true  
        });  
       this._loadData(id);
    }else {
      //没有更多了
      //console.log('没有更多了');
      this.setData({
          is_more:1
      });
      
    }
  },
  
  onPullDownRefresh: function () {
    this.getClassiData(this.data.page);
  },
  screenTap: function (e) {
    this.setData({
      currentTab: e.currentTarget.dataset.idx
    });
  },
	previewImage: function (e) {
    wx.previewImage({
      //从<image>的data-current取到current，得到String类型的url路径
      current: e.currentTarget.dataset.current,
      urls: [e.currentTarget.dataset.current] // 需要预览的图片http链接列表
    })
  },
});